package com.zr.service.impl;

import java.util.List;

import com.zr.dao.UserDao;
import com.zr.dao.impl.UserDaoImpl;
import com.zr.model.User;
import com.zr.model.UserRole;
import com.zr.service.UserService;

/**
 * @Description
 * @author 郑少杰
 * @date 2017年9月13日 下午2:29:35
 * @version V1.3.1
 */

public class UserServiceImpl implements UserService {
    UserDao userdao = new UserDaoImpl();

    /**
     * Description 根据用户和密码进行登录验证
     * 
     * @param userName 用户名
     * @param userPassWd 用户密码
     * @return 无论成功与否都返回user对象
     * @see com.zr.service.UserService#login(java.lang.String, java.lang.String)
     */

    @Override
    public User login(String userName, String userPassWd) {
        User user = userdao.login(userName, userPassWd);
        return user;

    }

    /**
     * Description
     * 
     * @param username
     * @param userPassWd
     * @param roleId
     * @return
     * @see com.zr.service.UserService#addUser(java.lang.String, java.lang.String, java.lang.String)
     */

    @Override
    public boolean addUser(String username, String userPassWd, String roleId) {

        return userdao.addUser(username, userPassWd, Integer.parseInt(roleId));
    }

    /**
     * Description
     * 
     * @param page
     * @param pageSize
     * @return
     * @see com.zr.service.UserService#getAllUser(java.lang.String, java.lang.String)
     */

    @Override
    public List<UserRole> getAllUser(String page, String pageSize) {
        List<UserRole> list =
                userdao.getUserRoles(Integer.parseInt(page), Integer.parseInt(pageSize));
        return list;
    }

    /**
     * Description
     * 
     * @return
     * @see com.zr.service.UserService#getAllUserNum()
     */

    @Override
    public int getAllUserNum() {

        return userdao.getAllUserNum();
    }



}
